package com.itheima.arraylist;

import com.itheima.domain.Student;

import java.util.ArrayList;

public class Test02 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Student> list = new ArrayList<>();
        //创建学生对象
        Student student1 = new Student("张三", 45);
        Student student2 = new Student("李四", 48);
        Student student3 = new Student("王五", 41);
        //添加学生对象到list集合中
        list.add(student1);
        list.add(student2);
        list.add(student3);
        //遍历list集合
        for (int i = 0; i < list.size(); i++) {
            //list.get(i)
            //输出list集合的索引
            System.out.println(list.get(i));
        }
    }
}
